package com.wanmait.computershop.webController;

import com.wanmait.computershop.dao.OrderDAO;
import com.wanmait.computershop.vo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("web")
public class WebOrdersController {
    @GetMapping("orders")
    public String orders(HttpSession session, Model model){
        User loginUser = (User)session.getAttribute("loginUser");

        model.addAttribute("orderList", OrderDAO.selectAllByUid(loginUser.getId()));
        return "web/orders";
    }
}
